<template>
  <el-form :inline="true" :model="form" status-icon class="demo-form-inline">
    <el-form-item label="搜索关键词">
      <el-input v-model="form.keywords" placeholder="请输入关键词"></el-input>
    </el-form-item>
    <el-form-item label="活动区域">
      <el-select v-model="form.category" clearable placeholder="请选择商品类别">
        <el-option
          :label="item.name"
          v-for="item in cateList"
          :key="item.id"
          :value="item.id"
        ></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="addGoods">
        添加商品
      </el-button>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  props: ["cateList"],
  data() {
    return {
      form: {
        keywords: "",
        category: "",
      },
      rules: [],
    };
  },
  methods: {
    onSubmit() {
      this.$emit("search", this.form, () => {
        this.form.keywords = "";
        this.form.category = "";
      });
    },
    addGoods(){
      this.$router.push({
        name : 'GoodAdd'
      })
    }
  },
};
</script>